package demo1;
import java.util.Timer;
import java.util.TimerTask;
public class MyTimer {
    public static void main(String[] args) {
        Timer timer=new Timer();//有前台线程
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("hello"+1000);
            }
        },1000);
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("hello"+2000);
            }
        },2000);
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("hello"+3000);
            }
        },3000);
    }
    }
